<admintpl file="header"/>
</head>
<body>
<div class="wrap">
    <form method="post" class="form-horizontal " id="myform"  action="{:U('Admin/Column/addColumnType')}">
         <div class="control-group">
            <label class="span1 control-label" style="width: 90px;">类型名称</label>
            <div class="span3">
            	<input type="text" name="name" value="" id="name">
            </div>
        </div>

		<div class="control-group">
			<label class="span1 control-label" style="width: 90px;">权重</label>
			<div class="span3">
				<input type="text" name="weight" value="" id="weight">
			</div>
		</div>
        
		<input type="text" name="column_id" id="column_id" value="<?php echo $column_id;?>">
        <div class="form-actions" style="padding-left:260px;">
            <a class="btn btn-primary" id="ajaxform">提 交</a>
            &nbsp;&nbsp;<a class="btn" id="ajaxback">{:L('BACK')}</a>
        </div>
    </form>
</div>
<script src="__PUBLIC__/js/common.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/content_addtop.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/ueditor/ueditor.all.min.js"></script>
<script type="text/javascript"
        src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.10.0/jquery.validate.min.js"></script>
<script src="__PUBLIC__/js/layer/layer.js"></script>
<script>
$(function(){
	$("[name='administrator_checbox']").click(function(){
		var administrator_id = $(this).val();
		var administrator_name = $(this).attr('administrator_name');
		
		var administrator_hidden_ids = $("#administrator_hidden_ids").val();
		var administrator_values = $("#administrator").val();
		
		var ids_arr = administrator_hidden_ids.split(",");         
		var values_arr = administrator_values.split(",");   
		
		if(ids_arr.indexOf(administrator_id) == '-1'){
			administrator_hidden_ids+=administrator_id+',';
			administrator_values+=administrator_name+',';
			$("#administrator").val(administrator_values);
			$("#administrator_hidden_ids").val(administrator_hidden_ids);
		}else{
			$.each(ids_arr,function(index,item){
				 if(item==administrator_id){
					 ids_arr.splice(index,1);
					 values_arr.splice(index,1);
				 }
			}) 
			administrator_hidden_ids = ids_arr.join(",");
			administrator_values = values_arr.join(",");
			$("#administrator").val(administrator_values);
			$("#administrator_hidden_ids").val(administrator_hidden_ids);
		}
	})
})

// ajax 提交表单
$(document).ready(function(){
    $("#ajaxform").click(function(){    // 提交按钮触发事件
        var tourl = $("#myform").attr("action");    // 获取 表单的 提交地址
        var name = $("#name").val();
		var weight  = $("#weight").val();
		var column_id = $("#column_id").val();
        $.post(tourl,{name:name,weight:weight,column_id:column_id},function(result){
        	if(result == '1'){
        		var msg = '添加成功';
        	}else{
        		var msg = '添加失败';
        	}
        	
    		parent.layer.msg(msg,{time:2000},1,function(a){
        		
    		});
    		setTimeout(function(){
    			var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
    			parent.layer.close(index);
    		}, 1000);
          });
    });
    $("#ajaxback").click(function(){
    	var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
		parent.layer.close(index);
    });
});
</script>
</body>
</html>